//
//  FlowChartController.swift
//  ANOA
//
//  Created by 邱仙凯 on 2020/11/12.
//  Copyright © 2020 zwb. All rights reserved.
//

import UIKit
import Kingfisher
class FlowImageVC: UIViewController {
    private lazy var img:UIImageView = {
       let v = UIImageView()
        return v
    }()
    
    private  var process:String!
    private  var voc_cd:String!
    private  var vou_id:String!
 
    private lazy var tableView:UITableView = {
       let v = UITableView()
        return v
    }()
     
    
    init(process:String,voc_cd:String,vou_id:String) {
        self.process = process
        self.voc_cd = voc_cd
        self.vou_id = vou_id
        super.init(nibName: nil, bundle: nil)
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.title = "流程图"
        self.view.backgroundColor = .white
        tableView.frame = self.view.bounds
        self.view.addSubview(tableView)
        img.frame = CGRect(x: 0, y: 0, width: KSGlobal.screenW, height: 250)
        self.tableView.tableHeaderView = img
        self.tableView.tableFooterView = UIView()
        
        var api:API?
        if process != "" {
            api = API.auditFlow(.getFlowPic(process: process))
        } else {  //  列表进来查看流程图
            api = API.auditFlow(.getFlowPicByVocVou(voc_cd: voc_cd, vou_id: vou_id))
        }
        
        
        KSNetwork.shared.doRequest(api!) { (data:BaseResult<OperateResult>) in
            if data.flag == TRUE {
                if let info = data.infoObjCombine {
                    
                    let resource = KF.ImageResource(downloadURL: URL(string:configURL(latter:info.img_url.unwrap))!)
                    self.img.kf.setImage(with: resource, placeholder: UIImage(named: "ld"))
             
                }
            } else {
                KSToast(data.errorCombine.unwrap)
            }
        }
     
        
     }
}
